#ifndef __AUDIODEVICE_INCLUDED
#define __AUDIODEVICE_INCLUDED

namespace Audio
{

	struct CreateVoiceArgument
	{

	};


	class AudioManagerCallback : public IAudioDeviceCallBack
	{
	public:
		AudioManagerCallback(AudioManager* m) : mgr(m){}

		virtual void OnNeedMoreData(void* context);
		virtual void OnStreamEnd(void* context);
		virtual void OnVoiceError(void* context);
	
	private:
		AudioManager* mgr;

	};
	
	class AudioManager : public ErroableObject, public IRunable
	{
	public:
		AudioManager();
		~AudioManager();			
		
		void Init();
		void Destroy();

		virtual void Run();
		virtual UINT32 ReturnCode();

		void ProcessCommands();
		AudioVoice* CreateVoice(const String& name);
		void DestroyVoice(AudioVoice* voice);
		void SetVolume(AudioVoice* voice, float vol);
		void Play(AudioVoice* voice);
		void Stop(AudioVoice* voice);
		void SendCommand(AudioCommand* command);
		
	private:
		
		IAudioDevice*				device;
		std::list<AudioVoice*>      voices;

		std::queue<AudioCommand*>	commands;
		ILocker*					locker;
		IEvent*						triggerEvent;
		IThread*					workingThread;
		IFactory*					factory;
		AudioManagerCallback*		engineCallback;
	};

}



#endif //__AUDIODEVICE_INCLUDED